package com.example.javaee_blog.mapper;


import com.example.javaee_blog.model.BlogInfo;
import com.example.javaee_blog.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    @Select("select * from blog where delete_flag = 0 order by create_time desc")
    List<BlogInfo> selectAll();

    @Select("select * from blog where delete_flag = 0 and id = #{blogId}")
    BlogInfo selectById(Integer blogId);

    @Insert("insert into blog (title, content, user_id) values (#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);

    Integer updateBlog(BlogInfo blogInfo);

}
